package com.ateam.biz.impl;

import java.util.List;

import com.ateam.biz.SharesBiz;
import com.ateam.dao.SharesDao;
import com.ateam.pojo.Shares;
import com.ateam.pojo.Users;

/** 
* @author WuYuan
* 
*/
public class SharesBizImpl implements SharesBiz {
	private SharesDao sharesDao;
	
	public SharesDao getSharesDao() {
		return sharesDao;
	}

	public void setSharesDao(SharesDao sharesDao) {
		this.sharesDao = sharesDao;
	}

	@Override
	public int addShareByUser(Shares share, Users u, int groupid, int projectid) {
		share.setUserid(u.getUserid());
		share.setUsername(u.getUsername());
		share.setHead(u.getHead());
		share.setGroupid(groupid);//单人发状态默认1组
		share.setProjectid(projectid);////单人发状态默认1项目
		try {
			return sharesDao.addShare(share);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public List<Shares> getShares(int companyid) {
		try {
			return sharesDao.getShares(companyid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Shares> getSharesByProjectid(int projectid) {
		try {
			return sharesDao.getSharesByProjectid(projectid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Shares> getSharesByGroupid(int groupid) {
		try {
			return sharesDao.getSharesByGroupid(groupid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Shares> getSharesByUserid(int userid) {
		try {
			return sharesDao.getSharesByUserid(userid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
